FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

RUN ln -s /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libdl.so
RUN apt-get update
RUN apt-get install -y libgdiplus
RUN ln -s /usr/lib/libgdiplus.so /lib/x86_64-linux-gnu/libgdiplus.so
RUN apt-get install -y libc6-dev


FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY Batman.Jianbei.Forum/Batman.Jianbei.Forum.csproj ./Batman.Jianbei.Forum/
COPY Batman.Cms.Core/Batman.Cms.Core.csproj ./Batman.Cms.Core/
COPY Batman.Maintenance/Batman.Maintenance.csproj ./Batman.Maintenance/

COPY ./Batman.Jianbei.Forum/ ./Batman.Jianbei.Forum
COPY ./Batman.Cms.Core/ ./Batman.Cms.Core
COPY ./Batman.Maintenance/ ./Batman.Maintenance
COPY ./Libs/ ./Libs

RUN dotnet restore ./Libs/Batman.Cache/Batman.Cache.csproj
RUN dotnet restore ./Batman.Jianbei.Forum/Batman.Jianbei.Forum.csproj


WORKDIR /src/
RUN dotnet build Batman.Jianbei.Forum/Batman.Jianbei.Forum.csproj -c Release -o /app

FROM build AS publish
RUN dotnet publish Batman.Jianbei.Forum/Batman.Jianbei.Forum.csproj -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Batman.Jianbei.Forum.dll"]
